<template>
    <div>
        <div class="item-box">
            <div class="item" @click="gotoDetail(serviceData.id)">
                <img
                    v-if="serviceData.photos[0]?.url"
                    :src="servicePort + serviceData.photos[0]?.url"
                />
                <img v-else :src="servicePort + '/vehicle/default_img.png'" />

                <div class="topic">
                    <h4 class="description">
                        <el-tooltip :content="serviceData.description" placement="top">
                            {{ serviceData.description }}
                        </el-tooltip>
                    </h4>
                    <div class="service_point">
                        <el-tooltip :content="serviceData.service_point" placement="top">
                            服务点： {{ serviceData.service_point }}
                        </el-tooltip>
                    </div>
                    <p>
                        原价：<span class="origin-pric">{{
                            (serviceData.money + 20).toFixed(2)
                        }}</span
                        >&nbsp; 活动价：<span class="pric"
                            >￥{{ serviceData.money.toFixed(2) }}</span
                        >
                    </p>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { servicePort } from '../../request'
import { useRouter } from 'vue-router'
const props = defineProps({
    serviceData: Object
})
const router = useRouter()

const gotoDetail = (id) => {
    router.push({
        path: `/detail/${id}`
    })
}
</script>

<style lang="scss" scoped>
.item-box {
    height: 350px;
    width: 100%;
    display: flex;

    .item {
        height: 350px;
        width: 100%;
        border: 1px solid #eee;
        border-radius: 5px;
        box-shadow:
            -2px -2px 2px #eee,
            2px 2px 2px #eee;
        margin-right: 10px;
        padding: 10px 10px;
        cursor: pointer;

        img {
            width: 240px;
            height: 240px;
        }

        .topic {
            width: 200px;
            margin: 10px auto;

            h4 {
                line-height: 1.5;
            }
            .service_point {
                font-size: 12px;
                color: #88888888;
                margin-top: 10px;
            }

            .description {
                overflow: hidden;
                text-wrap: nowrap;
                text-overflow: ellipsis;
            }

            p {
                font-size: 12px;
                color: #88888888;

                .origin-pric {
                    text-decoration: line-through;
                }

                .pric {
                    color: #ff0036;
                    font-size: 16px;
                }
            }
        }
    }
}
</style>
